package org.htmlparser.lexer;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectOutputStream;
import java.io.PrintStream;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import org.htmlparser.http.ConnectionManager;
import org.htmlparser.util.ParserException;

public class Page
  implements Serializable
{
  public static final String DEFAULT_CHARSET = "ISO-8859-1";
  public static final String DEFAULT_CONTENT_TYPE = "text/html";
  public static final char EOF = 65535;
  static Class class$java$lang$String;
  protected static ConnectionManager mConnectionManager = new ConnectionManager();
  protected String mBaseUrl;
  protected transient URLConnection mConnection;
  protected PageIndex mIndex;
  protected Source mSource;
  protected String mUrl;

  public Page()
  {
    this("");
  }

  public Page(InputStream paramInputStream, String paramString)
    throws UnsupportedEncodingException
  {
    if (paramInputStream == null)
      throw new IllegalArgumentException("stream cannot be null");
    if (paramString == null)
      paramString = "ISO-8859-1";
    this.mSource = new InputStreamSource(paramInputStream, paramString);
    this.mIndex = new PageIndex(this);
    this.mConnection = null;
    this.mUrl = null;
    this.mBaseUrl = null;
  }

  public Page(String paramString)
  {
    this(paramString, null);
  }

  public Page(String paramString1, String paramString2)
  {
    if (paramString1 == null)
      throw new IllegalArgumentException("text cannot be null");
    if (paramString2 == null)
      paramString2 = "ISO-8859-1";
    this.mSource = new StringSource(paramString1, paramString2);
    this.mIndex = new PageIndex(this);
    this.mConnection = null;
    this.mUrl = null;
    this.mBaseUrl = null;
  }

  public Page(URLConnection paramURLConnection)
    throws ParserException
  {
    if (paramURLConnection == null)
      throw new IllegalArgumentException("connection cannot be null");
    setConnection(paramURLConnection);
    this.mBaseUrl = null;
  }

  public Page(Source paramSource)
  {
    if (paramSource == null)
      throw new IllegalArgumentException("source cannot be null");
    this.mSource = paramSource;
    this.mIndex = new PageIndex(this);
    this.mConnection = null;
    this.mUrl = null;
    this.mBaseUrl = null;
  }

  static Class class$(String paramString)
  {
    Class localClass;
    try
    {
      localClass = Class.forName(paramString);
      return localClass;
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
    }
  }

  public static String findCharset(String paramString1, String paramString2)
  {
    String str;
    Class localClass1;
    try
    {
      Class localClass2;
      localClass1 = Class.forName("java.nio.charset.Charset");
      Class[] arrayOfClass = new Class[1];
      if (class$java$lang$String == null)
      {
        localClass2 = class$("java.lang.String");
        class$java$lang$String = localClass2;
        arrayOfClass[0] = localClass2;
        Method localMethod = localClass1.getMethod("forName", arrayOfClass);
        Object[] arrayOfObject = new Object[1];
        arrayOfObject[0] = paramString1;
        Object localObject = localMethod.invoke(null, arrayOfObject);
        label162: str = (String)localClass1.getMethod("name", new Class[0]).invoke(localObject, new Object[0]);
      }
      else
      {
        localClass2 = class$java$lang$String;
      }
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      str = paramString1;
      break label162:
    }
    catch (NoSuchMethodException localNoSuchMethodException)
    {
      str = paramString1;
      break label162:
    }
    catch (IllegalAccessException localIllegalAccessException)
    {
      str = paramString1;
      break label162:
    }
    catch (InvocationTargetException localInvocationTargetException)
    {
      str = paramString2;
      System.out.println("unable to determine cannonical charset name for " + paramString1 + " - using " + paramString2);
      return str;
    }
  }

  public static ConnectionManager getConnectionManager()
  {
    return mConnectionManager;
  }

  // ERROR //
  private void readObject(java.io.ObjectInputStream paramObjectInputStream)
    throws IOException, ClassNotFoundException
  {
    // Byte code:
    //   0: aload_1
    //   1: invokevirtual 175	java/io/ObjectInputStream:readBoolean	()Z
    //   4: ifeq +120 -> 124
    //   7: aload_1
    //   8: invokevirtual 179	java/io/ObjectInputStream:readInt	()I
    //   11: istore_3
    //   12: aload_1
    //   13: invokevirtual 182	java/io/ObjectInputStream:readObject	()Ljava/lang/Object;
    //   16: checkcast 138	java/lang/String
    //   19: astore 4
    //   21: aload_1
    //   22: invokevirtual 185	java/io/ObjectInputStream:defaultReadObject	()V
    //   25: aload_0
    //   26: invokevirtual 188	org/htmlparser/lexer/Page:getUrl	()Ljava/lang/String;
    //   29: ifnull +25 -> 54
    //   32: new 190	java/net/URL
    //   35: dup
    //   36: aload_0
    //   37: invokevirtual 188	org/htmlparser/lexer/Page:getUrl	()Ljava/lang/String;
    //   40: invokespecial 191	java/net/URL:<init>	(Ljava/lang/String;)V
    //   43: astore 5
    //   45: aload_0
    //   46: aload 5
    //   48: invokevirtual 195	java/net/URL:openConnection	()Ljava/net/URLConnection;
    //   51: invokevirtual 86	org/htmlparser/lexer/Page:setConnection	(Ljava/net/URLConnection;)V
    //   54: new 197	org/htmlparser/lexer/Cursor
    //   57: dup
    //   58: aload_0
    //   59: iconst_0
    //   60: invokespecial 200	org/htmlparser/lexer/Cursor:<init>	(Lorg/htmlparser/lexer/Page;I)V
    //   63: astore 7
    //   65: iconst_0
    //   66: istore 8
    //   68: iload 8
    //   70: iload_3
    //   71: if_icmpge +46 -> 117
    //   74: aload_0
    //   75: aload 7
    //   77: invokevirtual 204	org/htmlparser/lexer/Page:getCharacter	(Lorg/htmlparser/lexer/Cursor;)C
    //   80: pop
    //   81: iinc 8 1
    //   84: goto -16 -> 68
    //   87: astore 6
    //   89: new 169	IOException
    //   92: dup
    //   93: aload 6
    //   95: invokevirtual 106	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   98: invokespecial 205	IOException:<init>	(Ljava/lang/String;)V
    //   101: athrow
    //   102: astore 9
    //   104: new 169	IOException
    //   107: dup
    //   108: aload 9
    //   110: invokevirtual 106	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   113: invokespecial 205	IOException:<init>	(Ljava/lang/String;)V
    //   116: athrow
    //   117: aload_0
    //   118: aload 4
    //   120: invokevirtual 208	org/htmlparser/lexer/Page:setUrl	(Ljava/lang/String;)V
    //   123: return
    //   124: aload_1
    //   125: invokevirtual 182	java/io/ObjectInputStream:readObject	()Ljava/lang/Object;
    //   128: checkcast 138	java/lang/String
    //   131: astore_2
    //   132: aload_1
    //   133: invokevirtual 185	java/io/ObjectInputStream:defaultReadObject	()V
    //   136: aload_0
    //   137: aload_2
    //   138: invokevirtual 208	org/htmlparser/lexer/Page:setUrl	(Ljava/lang/String;)V
    //   141: goto -18 -> 123
    //
    // Exception table:
    //   from	to	target	type
    //   45	54	87	ParserException
    //   74	81	102	ParserException
  }

  public static void setConnectionManager(ConnectionManager paramConnectionManager)
  {
    mConnectionManager = paramConnectionManager;
  }

  private void writeObject(ObjectOutputStream paramObjectOutputStream)
    throws IOException
  {
    if (getConnection() != null)
    {
      paramObjectOutputStream.writeBoolean(true);
      paramObjectOutputStream.writeInt(this.mSource.offset());
      paramObjectOutputStream.writeObject(getUrl());
      setUrl(getConnection().getURL().toExternalForm());
      Source localSource = getSource();
      this.mSource = null;
      PageIndex localPageIndex = this.mIndex;
      this.mIndex = null;
      paramObjectOutputStream.defaultWriteObject();
      this.mSource = localSource;
      this.mIndex = localPageIndex;
    }
    while (true)
    {
      return;
      paramObjectOutputStream.writeBoolean(false);
      String str = getUrl();
      paramObjectOutputStream.writeObject(str);
      setUrl(null);
      paramObjectOutputStream.defaultWriteObject();
      setUrl(str);
    }
  }

  public void close()
    throws IOException
  {
    if (getSource() != null)
      getSource().destroy();
  }

  public int column(int paramInt)
  {
    return this.mIndex.column(paramInt);
  }

  public int column(Cursor paramCursor)
  {
    return this.mIndex.column(paramCursor);
  }

  public URL constructUrl(String paramString1, String paramString2)
    throws MalformedURLException
  {
    return constructUrl(paramString1, paramString2, false);
  }

  public URL constructUrl(String paramString1, String paramString2, boolean paramBoolean)
    throws MalformedURLException
  {
    URL localURL;
    String str;
    int i;
    if ((!(paramBoolean)) && ('?' == paramString1.charAt(0)))
    {
      int k = paramString2.lastIndexOf(63);
      if (-1 != k)
        paramString2 = paramString2.substring(0, k);
      localURL = new URL(paramString2 + paramString1);
      str = localURL.getFile();
      i = 0;
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          if ((paramString1.startsWith("/")) || (!(str.startsWith("/."))))
            break label177;
          if (!(str.startsWith("/../")))
            break label141;
          str = str.substring(3);
          i = 1;
        }
        localURL = new URL(new URL(paramString2), paramString1);
      }
      label141: if ((!(str.startsWith("/./"))) && (!(str.startsWith("/."))))
        break;
      str = str.substring(2);
      i = 1;
    }
    while (true)
    {
      label177: int j = str.indexOf("/\\");
      if (-1 == j)
        break;
      str = str.substring(0, j + 1) + str.substring(j + 2);
      i = 1;
    }
    if (i != 0)
      localURL = new URL(localURL, str);
    return localURL;
  }

  protected void finalize()
    throws Throwable
  {
    close();
  }

  public String getAbsoluteURL(String paramString)
  {
    return getAbsoluteURL(paramString, false);
  }

  public String getAbsoluteURL(String paramString, boolean paramBoolean)
  {
    Object localObject;
    String str1;
    if ((paramString == null) || ("".equals(paramString)))
    {
      localObject = "";
      return localObject;
    }
    try
    {
      str1 = getBaseUrl();
      if (str1 == null)
      {
        str1 = getUrl();
        break label64:
        String str2 = constructUrl(paramString, str1, paramBoolean).toExternalForm();
        label64: localObject = str2;
      }
    }
    catch (MalformedURLException localMalformedURLException)
    {
      do
        while (true)
          localObject = paramString;
      while (str1 != null);
      localObject = paramString;
    }
  }

  public String getBaseUrl()
  {
    return this.mBaseUrl;
  }

  // ERROR //
  public char getCharacter(Cursor paramCursor)
    throws ParserException
  {
    // Byte code:
    //   0: aload_1
    //   1: invokevirtual 323	org/htmlparser/lexer/Cursor:getPosition	()I
    //   4: istore_2
    //   5: aload_0
    //   6: getfield 57	org/htmlparser/lexer/Page:mSource	Lorg/htmlparser/lexer/Source;
    //   9: invokevirtual 226	org/htmlparser/lexer/Source:offset	()I
    //   12: istore_3
    //   13: iload_3
    //   14: iload_2
    //   15: if_icmpne +130 -> 145
    //   18: aload_0
    //   19: getfield 57	org/htmlparser/lexer/Page:mSource	Lorg/htmlparser/lexer/Source;
    //   22: invokevirtual 326	org/htmlparser/lexer/Source:read	()I
    //   25: istore 13
    //   27: bipush 255
    //   29: iload 13
    //   31: if_icmpne +67 -> 98
    //   34: ldc 16
    //   36: istore 6
    //   38: bipush 13
    //   40: iload 6
    //   42: if_icmpne +37 -> 79
    //   45: bipush 10
    //   47: istore 6
    //   49: aload_0
    //   50: getfield 57	org/htmlparser/lexer/Page:mSource	Lorg/htmlparser/lexer/Source;
    //   53: invokevirtual 226	org/htmlparser/lexer/Source:offset	()I
    //   56: aload_1
    //   57: invokevirtual 323	org/htmlparser/lexer/Cursor:getPosition	()I
    //   60: if_icmpne +282 -> 342
    //   63: aload_0
    //   64: getfield 57	org/htmlparser/lexer/Page:mSource	Lorg/htmlparser/lexer/Source;
    //   67: invokevirtual 326	org/htmlparser/lexer/Source:read	()I
    //   70: istore 10
    //   72: bipush 255
    //   74: iload 10
    //   76: if_icmpne +171 -> 247
    //   79: bipush 10
    //   81: iload 6
    //   83: if_icmpne +12 -> 95
    //   86: aload_0
    //   87: getfield 64	org/htmlparser/lexer/Page:mIndex	Lorg/htmlparser/lexer/PageIndex;
    //   90: aload_1
    //   91: invokevirtual 329	org/htmlparser/lexer/PageIndex:add	(Lorg/htmlparser/lexer/Cursor;)I
    //   94: pop
    //   95: iload 6
    //   97: ireturn
    //   98: iload 13
    //   100: i2c
    //   101: istore 6
    //   103: aload_1
    //   104: invokevirtual 332	org/htmlparser/lexer/Cursor:advance	()V
    //   107: goto -69 -> 38
    //   110: astore 12
    //   112: new 81	ParserException
    //   115: dup
    //   116: new 146	java/lang/StringBuffer
    //   119: dup
    //   120: invokespecial 147	java/lang/StringBuffer:<init>	()V
    //   123: ldc_w 334
    //   126: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   129: aload_1
    //   130: invokevirtual 323	org/htmlparser/lexer/Cursor:getPosition	()I
    //   133: invokevirtual 337	java/lang/StringBuffer:append	(I)Ljava/lang/StringBuffer;
    //   136: invokevirtual 158	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   139: aload 12
    //   141: invokespecial 340	ParserException:<init>	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   144: athrow
    //   145: iload_3
    //   146: iload_2
    //   147: if_icmple +56 -> 203
    //   150: aload_0
    //   151: getfield 57	org/htmlparser/lexer/Page:mSource	Lorg/htmlparser/lexer/Source;
    //   154: iload_2
    //   155: invokevirtual 342	org/htmlparser/lexer/Source:getCharacter	(I)C
    //   158: istore 5
    //   160: iload 5
    //   162: istore 6
    //   164: aload_1
    //   165: invokevirtual 332	org/htmlparser/lexer/Cursor:advance	()V
    //   168: goto -130 -> 38
    //   171: astore 4
    //   173: new 81	ParserException
    //   176: dup
    //   177: new 146	java/lang/StringBuffer
    //   180: dup
    //   181: invokespecial 147	java/lang/StringBuffer:<init>	()V
    //   184: ldc_w 344
    //   187: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   190: iload_2
    //   191: invokevirtual 337	java/lang/StringBuffer:append	(I)Ljava/lang/StringBuffer;
    //   194: invokevirtual 158	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   197: aload 4
    //   199: invokespecial 340	ParserException:<init>	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   202: athrow
    //   203: new 81	ParserException
    //   206: dup
    //   207: new 146	java/lang/StringBuffer
    //   210: dup
    //   211: invokespecial 147	java/lang/StringBuffer:<init>	()V
    //   214: ldc_w 346
    //   217: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   220: iload_2
    //   221: invokevirtual 337	java/lang/StringBuffer:append	(I)Ljava/lang/StringBuffer;
    //   224: ldc_w 348
    //   227: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   230: aload_0
    //   231: getfield 57	org/htmlparser/lexer/Page:mSource	Lorg/htmlparser/lexer/Source;
    //   234: invokevirtual 226	org/htmlparser/lexer/Source:offset	()I
    //   237: invokevirtual 337	java/lang/StringBuffer:append	(I)Ljava/lang/StringBuffer;
    //   240: invokevirtual 158	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   243: invokespecial 349	ParserException:<init>	(Ljava/lang/String;)V
    //   246: athrow
    //   247: bipush 10
    //   249: iload 10
    //   251: i2c
    //   252: if_icmpne +45 -> 297
    //   255: aload_1
    //   256: invokevirtual 332	org/htmlparser/lexer/Cursor:advance	()V
    //   259: goto -180 -> 79
    //   262: astore 9
    //   264: new 81	ParserException
    //   267: dup
    //   268: new 146	java/lang/StringBuffer
    //   271: dup
    //   272: invokespecial 147	java/lang/StringBuffer:<init>	()V
    //   275: ldc_w 334
    //   278: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   281: aload_1
    //   282: invokevirtual 323	org/htmlparser/lexer/Cursor:getPosition	()I
    //   285: invokevirtual 337	java/lang/StringBuffer:append	(I)Ljava/lang/StringBuffer;
    //   288: invokevirtual 158	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   291: aload 9
    //   293: invokespecial 340	ParserException:<init>	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   296: athrow
    //   297: aload_0
    //   298: getfield 57	org/htmlparser/lexer/Page:mSource	Lorg/htmlparser/lexer/Source;
    //   301: invokevirtual 352	org/htmlparser/lexer/Source:unread	()V
    //   304: goto -225 -> 79
    //   307: astore 11
    //   309: new 81	ParserException
    //   312: dup
    //   313: new 146	java/lang/StringBuffer
    //   316: dup
    //   317: invokespecial 147	java/lang/StringBuffer:<init>	()V
    //   320: ldc_w 354
    //   323: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   326: aload_1
    //   327: invokevirtual 323	org/htmlparser/lexer/Cursor:getPosition	()I
    //   330: invokevirtual 337	java/lang/StringBuffer:append	(I)Ljava/lang/StringBuffer;
    //   333: invokevirtual 158	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   336: aload 11
    //   338: invokespecial 340	ParserException:<init>	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   341: athrow
    //   342: bipush 10
    //   344: aload_0
    //   345: getfield 57	org/htmlparser/lexer/Page:mSource	Lorg/htmlparser/lexer/Source;
    //   348: aload_1
    //   349: invokevirtual 323	org/htmlparser/lexer/Cursor:getPosition	()I
    //   352: invokevirtual 342	org/htmlparser/lexer/Source:getCharacter	(I)C
    //   355: if_icmpne -276 -> 79
    //   358: aload_1
    //   359: invokevirtual 332	org/htmlparser/lexer/Cursor:advance	()V
    //   362: goto -283 -> 79
    //   365: astore 8
    //   367: new 81	ParserException
    //   370: dup
    //   371: new 146	java/lang/StringBuffer
    //   374: dup
    //   375: invokespecial 147	java/lang/StringBuffer:<init>	()V
    //   378: ldc_w 344
    //   381: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   384: aload_1
    //   385: invokevirtual 323	org/htmlparser/lexer/Cursor:getPosition	()I
    //   388: invokevirtual 337	java/lang/StringBuffer:append	(I)Ljava/lang/StringBuffer;
    //   391: invokevirtual 158	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   394: aload 8
    //   396: invokespecial 340	ParserException:<init>	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   399: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   18	27	110	IOException
    //   103	107	110	IOException
    //   150	160	171	IOException
    //   63	72	262	IOException
    //   255	259	262	IOException
    //   309	342	262	IOException
    //   297	304	307	IOException
    //   342	362	365	IOException
  }

  public String getCharset(String paramString)
  {
    String str1;
    if (this.mSource == null)
      str1 = "ISO-8859-1";
    while (true)
    {
      if (paramString != null)
      {
        int i = paramString.indexOf("charset");
        if (i != -1)
        {
          String str2 = paramString.substring(i + "charset".length()).trim();
          if (str2.startsWith("="))
          {
            String str3 = str2.substring(1).trim();
            int j = str3.indexOf(";");
            if (j != -1)
              str3 = str3.substring(0, j);
            if ((str3.startsWith("\"")) && (str3.endsWith("\"")) && (1 < str3.length()))
              str3 = str3.substring(1, str3.length() - 1);
            if ((str3.startsWith("'")) && (str3.endsWith("'")) && (1 < str3.length()))
              str3 = str3.substring(1, str3.length() - 1);
            str1 = findCharset(str3, str1);
          }
        }
      }
      return str1;
      str1 = this.mSource.getEncoding();
    }
  }

  public URLConnection getConnection()
  {
    return this.mConnection;
  }

  public String getContentType()
  {
    Object localObject = "text/html";
    URLConnection localURLConnection = getConnection();
    if (localURLConnection != null)
    {
      String str = localURLConnection.getHeaderField("Content-Type");
      if (str != null)
        localObject = str;
    }
    return ((String)localObject);
  }

  public String getEncoding()
  {
    return getSource().getEncoding();
  }

  public String getLine(int paramInt)
  {
    return getLine(new Cursor(this, paramInt));
  }

  public String getLine(Cursor paramCursor)
  {
    int k;
    int l;
    int i = row(paramCursor);
    int j = this.mIndex.size();
    if (i < j)
    {
      k = this.mIndex.elementAt(i);
      int i1 = i + 1;
      if (i1 <= j)
        l = this.mIndex.elementAt(i1);
    }
    while (true)
    {
      while (true)
      {
        return getText(k, l);
        l = this.mSource.offset();
      }
      k = this.mIndex.elementAt(i - 1);
      l = this.mSource.offset();
    }
  }

  public Source getSource()
  {
    return this.mSource;
  }

  public String getText()
  {
    return getText(0, this.mSource.offset());
  }

  public String getText(int paramInt1, int paramInt2)
    throws IllegalArgumentException
  {
    String str;
    try
    {
      str = this.mSource.getString(paramInt1, paramInt2 - paramInt1);
      return str;
    }
    catch (IOException localIOException)
    {
      throw new IllegalArgumentException("can't get the " + (paramInt2 - paramInt1) + "characters at position " + paramInt1 + " - " + localIOException.getMessage());
    }
  }

  public void getText(StringBuffer paramStringBuffer)
  {
    getText(paramStringBuffer, 0, this.mSource.offset());
  }

  public void getText(StringBuffer paramStringBuffer, int paramInt1, int paramInt2)
    throws IllegalArgumentException
  {
    if ((this.mSource.offset() < paramInt1) || (this.mSource.offset() < paramInt2))
      throw new IllegalArgumentException("attempt to extract future characters from source" + paramInt1 + "|" + paramInt2 + " > " + this.mSource.offset());
    if (paramInt2 < paramInt1)
    {
      int j = paramInt2;
      paramInt2 = paramInt1;
      paramInt1 = j;
    }
    int i = paramInt2 - paramInt1;
    try
    {
      this.mSource.getCharacters(paramStringBuffer, paramInt1, i);
      return;
    }
    catch (IOException localIOException)
    {
      throw new IllegalArgumentException("can't get the " + (paramInt2 - paramInt1) + "characters at position " + paramInt1 + " - " + localIOException.getMessage());
    }
  }

  public void getText(char[] paramArrayOfChar, int paramInt1, int paramInt2, int paramInt3)
    throws IllegalArgumentException
  {
    if ((this.mSource.offset() < paramInt2) || (this.mSource.offset() < paramInt3))
      throw new IllegalArgumentException("attempt to extract future characters from source");
    if (paramInt3 < paramInt2)
    {
      int i = paramInt3;
      paramInt3 = paramInt2;
      paramInt2 = i;
    }
    (paramInt3 - paramInt2);
    try
    {
      this.mSource.getCharacters(paramArrayOfChar, paramInt1, paramInt2, paramInt3);
      return;
    }
    catch (IOException localIOException)
    {
      throw new IllegalArgumentException("can't get the " + (paramInt3 - paramInt2) + "characters at position " + paramInt2 + " - " + localIOException.getMessage());
    }
  }

  public String getUrl()
  {
    return this.mUrl;
  }

  public void reset()
  {
    getSource().reset();
    this.mIndex = new PageIndex(this);
  }

  public int row(int paramInt)
  {
    return this.mIndex.row(paramInt);
  }

  public int row(Cursor paramCursor)
  {
    return this.mIndex.row(paramCursor);
  }

  public void setBaseUrl(String paramString)
  {
    this.mBaseUrl = paramString;
  }

  // ERROR //
  public void setConnection(URLConnection paramURLConnection)
    throws ParserException
  {
    // Byte code:
    //   0: aload_0
    //   1: aload_1
    //   2: putfield 66	org/htmlparser/lexer/Page:mConnection	Ljava/net/URLConnection;
    //   5: aload_0
    //   6: invokevirtual 215	org/htmlparser/lexer/Page:getConnection	()Ljava/net/URLConnection;
    //   9: invokevirtual 436	java/net/URLConnection:connect	()V
    //   12: aload_0
    //   13: aload_0
    //   14: invokevirtual 438	org/htmlparser/lexer/Page:getContentType	()Ljava/lang/String;
    //   17: invokevirtual 440	org/htmlparser/lexer/Page:getCharset	(Ljava/lang/String;)Ljava/lang/String;
    //   20: astore 4
    //   22: aload_1
    //   23: invokevirtual 443	java/net/URLConnection:getContentEncoding	()Ljava/lang/String;
    //   26: astore 6
    //   28: aload 6
    //   30: ifnull +181 -> 211
    //   33: bipush 255
    //   35: aload 6
    //   37: ldc_w 445
    //   40: invokevirtual 305	java/lang/String:indexOf	(Ljava/lang/String;)I
    //   43: if_icmpeq +168 -> 211
    //   46: new 447	org/htmlparser/lexer/Stream
    //   49: dup
    //   50: new 449	java/util/zip/GZIPInputStream
    //   53: dup
    //   54: aload_0
    //   55: invokevirtual 215	org/htmlparser/lexer/Page:getConnection	()Ljava/net/URLConnection;
    //   58: invokevirtual 453	java/net/URLConnection:getInputStream	()Ljava/io/InputStream;
    //   61: invokespecial 456	java/util/zip/GZIPInputStream:<init>	(Ljava/io/InputStream;)V
    //   64: invokespecial 457	org/htmlparser/lexer/Stream:<init>	(Ljava/io/InputStream;)V
    //   67: astore 7
    //   69: aload_0
    //   70: new 53	org/htmlparser/lexer/InputStreamSource
    //   73: dup
    //   74: aload 7
    //   76: aload 4
    //   78: invokespecial 55	org/htmlparser/lexer/InputStreamSource:<init>	(Ljava/io/InputStream;Ljava/lang/String;)V
    //   81: putfield 57	org/htmlparser/lexer/Page:mSource	Lorg/htmlparser/lexer/Source;
    //   84: aload_0
    //   85: aload_1
    //   86: invokevirtual 239	java/net/URLConnection:getURL	()Ljava/net/URL;
    //   89: invokevirtual 242	java/net/URL:toExternalForm	()Ljava/lang/String;
    //   92: putfield 68	org/htmlparser/lexer/Page:mUrl	Ljava/lang/String;
    //   95: aload_0
    //   96: new 59	org/htmlparser/lexer/PageIndex
    //   99: dup
    //   100: aload_0
    //   101: invokespecial 62	org/htmlparser/lexer/PageIndex:<init>	(Lorg/htmlparser/lexer/Page;)V
    //   104: putfield 64	org/htmlparser/lexer/Page:mIndex	Lorg/htmlparser/lexer/PageIndex;
    //   107: return
    //   108: astore_3
    //   109: new 81	ParserException
    //   112: dup
    //   113: new 146	java/lang/StringBuffer
    //   116: dup
    //   117: invokespecial 147	java/lang/StringBuffer:<init>	()V
    //   120: ldc_w 459
    //   123: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   126: aload_0
    //   127: getfield 66	org/htmlparser/lexer/Page:mConnection	Ljava/net/URLConnection;
    //   130: invokevirtual 239	java/net/URLConnection:getURL	()Ljava/net/URL;
    //   133: invokevirtual 242	java/net/URL:toExternalForm	()Ljava/lang/String;
    //   136: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   139: ldc_w 461
    //   142: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   145: invokevirtual 158	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   148: aload_3
    //   149: invokespecial 340	ParserException:<init>	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   152: athrow
    //   153: astore_2
    //   154: new 81	ParserException
    //   157: dup
    //   158: new 146	java/lang/StringBuffer
    //   161: dup
    //   162: invokespecial 147	java/lang/StringBuffer:<init>	()V
    //   165: ldc_w 463
    //   168: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   171: aload_0
    //   172: getfield 66	org/htmlparser/lexer/Page:mConnection	Ljava/net/URLConnection;
    //   175: invokevirtual 239	java/net/URLConnection:getURL	()Ljava/net/URL;
    //   178: invokevirtual 242	java/net/URL:toExternalForm	()Ljava/lang/String;
    //   181: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   184: ldc_w 465
    //   187: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   190: aload_2
    //   191: invokevirtual 106	Throwable:getMessage	()Ljava/lang/String;
    //   194: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   197: ldc_w 467
    //   200: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   203: invokevirtual 158	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   206: aload_2
    //   207: invokespecial 340	ParserException:<init>	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   210: athrow
    //   211: aload 6
    //   213: ifnull +50 -> 263
    //   216: bipush 255
    //   218: aload 6
    //   220: ldc_w 469
    //   223: invokevirtual 305	java/lang/String:indexOf	(Ljava/lang/String;)I
    //   226: if_icmpeq +37 -> 263
    //   229: new 447	org/htmlparser/lexer/Stream
    //   232: dup
    //   233: new 471	java/util/zip/InflaterInputStream
    //   236: dup
    //   237: aload_0
    //   238: invokevirtual 215	org/htmlparser/lexer/Page:getConnection	()Ljava/net/URLConnection;
    //   241: invokevirtual 453	java/net/URLConnection:getInputStream	()Ljava/io/InputStream;
    //   244: new 473	java/util/zip/Inflater
    //   247: dup
    //   248: iconst_1
    //   249: invokespecial 475	java/util/zip/Inflater:<init>	(Z)V
    //   252: invokespecial 478	java/util/zip/InflaterInputStream:<init>	(Ljava/io/InputStream;Ljava/util/zip/Inflater;)V
    //   255: invokespecial 457	org/htmlparser/lexer/Stream:<init>	(Ljava/io/InputStream;)V
    //   258: astore 7
    //   260: goto -191 -> 69
    //   263: new 447	org/htmlparser/lexer/Stream
    //   266: dup
    //   267: aload_0
    //   268: invokevirtual 215	org/htmlparser/lexer/Page:getConnection	()Ljava/net/URLConnection;
    //   271: invokevirtual 453	java/net/URLConnection:getInputStream	()Ljava/io/InputStream;
    //   274: invokespecial 457	org/htmlparser/lexer/Stream:<init>	(Ljava/io/InputStream;)V
    //   277: astore 7
    //   279: goto -210 -> 69
    //   282: astore 8
    //   284: aload_0
    //   285: new 53	org/htmlparser/lexer/InputStreamSource
    //   288: dup
    //   289: aload 7
    //   291: ldc 10
    //   293: invokespecial 55	org/htmlparser/lexer/InputStreamSource:<init>	(Ljava/io/InputStream;Ljava/lang/String;)V
    //   296: putfield 57	org/htmlparser/lexer/Page:mSource	Lorg/htmlparser/lexer/Source;
    //   299: goto -215 -> 84
    //   302: astore 5
    //   304: new 81	ParserException
    //   307: dup
    //   308: new 146	java/lang/StringBuffer
    //   311: dup
    //   312: invokespecial 147	java/lang/StringBuffer:<init>	()V
    //   315: ldc_w 480
    //   318: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   321: aload_0
    //   322: getfield 66	org/htmlparser/lexer/Page:mConnection	Ljava/net/URLConnection;
    //   325: invokevirtual 239	java/net/URLConnection:getURL	()Ljava/net/URL;
    //   328: invokevirtual 242	java/net/URL:toExternalForm	()Ljava/lang/String;
    //   331: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   334: ldc_w 465
    //   337: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   340: aload 5
    //   342: invokevirtual 106	Throwable:getMessage	()Ljava/lang/String;
    //   345: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   348: ldc_w 467
    //   351: invokevirtual 153	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   354: invokevirtual 158	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   357: aload 5
    //   359: invokespecial 340	ParserException:<init>	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   362: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   5	12	108	java/net/UnknownHostException
    //   5	12	153	IOException
    //   69	84	282	UnsupportedEncodingException
    //   22	69	302	IOException
    //   69	84	302	IOException
    //   216	299	302	IOException
  }

  public void setEncoding(String paramString)
    throws ParserException
  {
    getSource().setEncoding(paramString);
  }

  public void setUrl(String paramString)
  {
    this.mUrl = paramString;
  }

  public String toString()
  {
    StringBuffer localStringBuffer;
    String str;
    if (this.mSource.offset() > 0)
    {
      localStringBuffer = new StringBuffer(43);
      int i = this.mSource.offset() - 40;
      if (i < 0)
      {
        i = 0;
        getText(localStringBuffer, i, this.mSource.offset());
        str = localStringBuffer.toString();
      }
    }
    while (true)
    {
      while (true)
      {
        return str;
        localStringBuffer.append("...");
      }
      str = super.toString();
    }
  }

  public void ungetCharacter(Cursor paramCursor)
    throws ParserException
  {
    paramCursor.retreat();
    int i = paramCursor.getPosition();
    try
    {
      if (('\n' == this.mSource.getCharacter(i)) && (i != 0) && ('\r' == this.mSource.getCharacter(i - 1)))
        paramCursor.retreat();
      return;
    }
    catch (IOException localIOException)
    {
      throw new ParserException("can't read a character at position " + paramCursor.getPosition(), localIOException);
    }
  }
}